package com.hksj.wlw.controller;

import com.hksj.common.core.model.Rest;
import com.hksj.wlw.dto.LeakWaterAlarmNumDTO;
import com.hksj.wlw.service.LeakWaterCockpitService;
import com.hksj.wlw.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author fjt
 * @data 2024/9/9 15:07
 * @describe todo
 */
@Api(tags = "无线漏水-驾驶舱")
@RestController
@RequestMapping("/api/wlw/cockpit")
public class LeakWaterCockpitController {

    @Autowired
    private LeakWaterCockpitService cockpitService;


    @PostMapping("/overView")
    @ApiOperation(value = "设备概览", notes = "设备概览",response = LeakWaterDeviceOverviewVo.class)
    public Rest<LeakWaterDeviceOverviewVo> deviceOverView(@RequestBody LeakWaterAlarmNumDTO dto){
        return Rest.ok(cockpitService.deviceOverView(dto));
    }


    @PostMapping("/queryAlarmNumByTime")
    @ApiOperation(value = "按天统计7天内的报警数量", notes = "按天统计7天内的报警数量",response = LeakWaterAlarmKindNumVo.class)
    public Rest<List<LeakWaterAlarmKindNumVo>> queryAlarmNumByTime(@RequestBody LeakWaterAlarmNumDTO dto){
        return Rest.ok(cockpitService.queryAlarmNumByTime(dto));
    }


    @PostMapping("/alarmList")
    @ApiOperation(value = "查询设备报警记录", notes = "查询设备报警记录，当报警状态为空时查全部状态的报警记录(最近7天)",response = LeakWaterAlarmVo.class)
    public Rest<List<LeakWaterAlarmVo>> queryAlarmList(@RequestBody LeakWaterAlarmNumDTO dto){
        return Rest.ok(cockpitService.queryAlarmList(dto));
    }


    @PostMapping("/alarmNum")
    @ApiOperation(value = "当日、本周报警数量查询", notes = "当日、本周报警数量查询",response = LeakWaterTotalOfAlarmVo.class)
    public Rest<LeakWaterTotalOfAlarmVo> alarmNum(@RequestBody LeakWaterAlarmNumDTO dto){
        return Rest.ok(cockpitService.alarmNum(dto));
    }


    @PostMapping("/topFive")
    @ApiOperation(value = "报警数量排名(前5)", notes = "报警数量排名(前5)",response = LeakWaterAlarmNumTopFiveVo.class)
    public Rest<List<LeakWaterAlarmNumTopFiveVo>> alarmNumRanking(@RequestBody LeakWaterAlarmNumDTO dto){
        return Rest.ok(cockpitService.alarmNumRanking(dto));
    }

}
